use Test::More qw/no_plan/;

use lib 'lib/';

require_ok('App::VisRE');

my $app = App::VisRE->new();

my @default_switches = qw/i x g/;
is_deeply($app->switches,\@default_switches, 'Default Switches');

$app->add_switch('m');
is_deeply($app->switches,['i', 'x', 'g', 'm'], 'Add Switch m');

$app->remove_switch('x');
is_deeply($app->switches,['i', 'g', 'm'], 'Remove Switch x');

is($app->re_file,'re.txt','Default save RE name');

$app->re_file('save_re.txt');
is($app->re_file,'save_re.txt','New save RE name');

is($app->has_match_file,'','match_file should be empty');

$app->match_file('load_file.txt');
is($app->match_file,'load_file.txt','match_file should be empty');

is($app->re,undef,'Undef RE');
is($app->re('foo'),'foo','RE String');
is($app->has_re,1,'Has RE');

is($app->re('foo'),'foo','RE String');
is($app->re(12),'12','RE Number');
is($app->re('\w'),'\w','RE \w');
is($app->re('\w*'),'\w*','RE \w*');
is($app->re('(?<zip_code>\d{5})'),'(?<zip_code>\d{5})','RE named capture');
is($app->match_string,undef,'Blank match string');
is($app->match_string('foo bar baz'),'foo bar baz','Blank match string');
is($app->has_match_string,1,'Has match string');
isnt($app->has_match_string,0,'Has match string negated');

my $app2 = App::VisRE->new();

# Try a blank search (should fail)
is($app2->do_search,"Missing: regular expression and match string",'Empty search should fail');

# Set the match string and try a search (should fail)
$app2->match_string('foobar');
is($app2->do_search,"Missing: regular expression",'Empty re should fail');

# Unset the match string and set the re (should fail)
my $app3 = App::VisRE->new();
$app3->re('foo');
is($app3->do_search,"Missing: match string",'Empty match string should fail');
